(function(vc){
    vc.extends({
        propTypes: {
           emitChooseAffiliateWithdrawal:vc.propTypes.string,
           emitLoadData:vc.propTypes.string
        },
        data:{
            chooseAffiliateWithdrawalInfo:{
                affiliateWithdrawals:[],
                _currentAffiliateWithdrawalName:'',
            }
        },
        _initMethod:function(){
        },
        _initEvent:function(){
            vc.on('chooseAffiliateWithdrawal','openChooseAffiliateWithdrawalModel',function(_param){
                $('#chooseAffiliateWithdrawalModel').modal('show');
                vc.component._refreshChooseAffiliateWithdrawalInfo();
                vc.component._loadAllAffiliateWithdrawalInfo(1,10,'');
            });
        },
        methods:{
            _loadAllAffiliateWithdrawalInfo:function(_page,_row,_name){
                var param = {
                    params:{
                        page:_page,
                        row:_row,
                        communityId:vc.getCurrentCommunity().communityId,
                        name:_name
                    }
                };

                //发送get请求
               vc.http.apiGet('affiliateWithdrawal.listAffiliateWithdrawal',
                             param,
                             function(json){
                                var _affiliateWithdrawalInfo = JSON.parse(json);
                                vc.component.chooseAffiliateWithdrawalInfo.affiliateWithdrawals = _affiliateWithdrawalInfo.affiliateWithdrawals;
                             },function(){
                                console.log('请求失败处理');
                             }
                           );
            },
            chooseAffiliateWithdrawal:function(_affiliateWithdrawal){
                if(_affiliateWithdrawal.hasOwnProperty('name')){
                     _affiliateWithdrawal.affiliateWithdrawalName = _affiliateWithdrawal.name;
                }
                vc.emit($props.emitChooseAffiliateWithdrawal,'chooseAffiliateWithdrawal',_affiliateWithdrawal);
                vc.emit($props.emitLoadData,'listAffiliateWithdrawalData',{
                    affiliateWithdrawalId:_affiliateWithdrawal.affiliateWithdrawalId
                });
                $('#chooseAffiliateWithdrawalModel').modal('hide');
            },
            queryAffiliateWithdrawals:function(){
                vc.component._loadAllAffiliateWithdrawalInfo(1,10,vc.component.chooseAffiliateWithdrawalInfo._currentAffiliateWithdrawalName);
            },
            _refreshChooseAffiliateWithdrawalInfo:function(){
                vc.component.chooseAffiliateWithdrawalInfo._currentAffiliateWithdrawalName = "";
            }
        }

    });
})(window.vc);
